<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地图找房</title>
    <link rel="stylesheet" th:href="@{/airent/plugins/bootstrap/bootstrap-4.4.1-dist/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/airent/common/css/nav.css}">
    <link rel="stylesheet" th:href="@{/airent/css/index.css}">
    <link rel="stylesheet" th:href="@{/airent/css/searchmap.css}">
    <link rel="stylesheet" th:href="@{/airent/plugins/other/animate.min.css}" />
    <link rel="icon" th:href="@{/airent/common/imgs/icon.ico}" type="images/x-ico" />
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
    <script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=2gQBx0YMMZFbGo0j9HkQ4CncLx1rrFzD"></script>
    <script src="http://api.map.baidu.com/library/GeoUtils/1.2/src/GeoUtils.js"></script>
    <script src="http://api.map.baidu.com/library/InfoBox/1.2/src/InfoBox_min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=2gQBx0YMMZFbGo0j9HkQ4CncLx1rrFzD"></script>
    <script type="text/javascript" th:src="@{/airent/js/jquery-3.5.1.js}"></script>

</head>

<body>
<!-- 导航栏 - 开始 -->
<nav class="navbar navbar-expand-lg navbar-light bg-light " id="nav">

    <div class="collapse navbar-collapse col-md-10 offset-md-1 animate__animated  animate__zoomIn"
         id="navbarSupportedContent">
        <a id="logo-img" class="navbar-brand" href="../view/index.html">
            <img alt="Brand" th:src="@{/airent/common/imgs/logo_small.png}">
        </a>
        <ul class="navbar-nav mr-auto">
            <li class="nav-item">
                <a id="select-city" class="nav-link" href="#"><svg id="city-icon" class="bi bi-building" width="1em"
                                                                   height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                    <path fill-rule="evenodd"
                          d="M15.285.089A.5.5 0 0 1 15.5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5V14h-1v1.5a.5.5 0 0 1-.5.5H1a.5.5 0 0 1-.5-.5v-6a.5.5 0 0 1 .418-.493l5.582-.93V3.5a.5.5 0 0 1 .324-.468l8-3a.5.5 0 0 1 .46.057zM7.5 3.846V8.5a.5.5 0 0 1-.418.493l-5.582.93V15h8v-1.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5V15h2V1.222l-7 2.624z" />
                    <path fill-rule="evenodd" d="M6.5 15.5v-7h1v7h-1z" />
                    <path
                            d="M2.5 11h1v1h-1v-1zm2 0h1v1h-1v-1zm-2 2h1v1h-1v-1zm2 0h1v1h-1v-1zm6-10h1v1h-1V3zm2 0h1v1h-1V3zm-4 2h1v1h-1V5zm2 0h1v1h-1V5zm2 0h1v1h-1V5zm-2 2h1v1h-1V7zm2 0h1v1h-1V7zm-4 0h1v1h-1V7zm0 2h1v1h-1V9zm2 0h1v1h-1V9zm2 0h1v1h-1V9zm-4 2h1v1h-1v-1zm2 0h1v1h-1v-1zm2 0h1v1h-1v-1z" />
                </svg><span id="cityname">选择城市<span></a>
            </li>
        </ul>
        <ul class="navbar-nav mr-5 ">
            <li class="nav-item">
                <a class="nav-link" href="searchhouse.html">租房</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="issuehouse.html">发布房源</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="roomate.html">寻找室友</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="PriceTrendChart.html">房价走势</a>
            </li>
            <li  class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
                   aria-haspopup="true" aria-expanded="false">
                    指南
                </a>
                <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                    <a class="dropdown-item" href="Agreement.html">用户协议</a>
                    <a class="dropdown-item" href="Potplayer.html">隐私政策</a>
                    <a class="dropdown-item" href="Commitment.html">服务承诺</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="#">关于我们</a>
                </div>
            </li>
        </ul>
        <a href="login_register.html" id="login-button" class="btn btn-outline-success active animate__animated animate__pulse"
           role="button" aria-pressed="true">登录/注册</a>
        <!-- <a href="register.html" id="register-button"
          class="btn btn-outline-success active animate__animated animate__pulse" role="button" aria-pressed="true">注册</a> -->
    </div>
</nav>

<!-- 导航栏 - 结束 -->

<!-- 地图找房 - 开始 -->

<div class="search-up">
    <div class="findhouse">
        <div class="search-box" >
            <div class="input-group">
                <input type="text" class="form-control" id="areaName" name="areaName" th:value="${areaName}" placeholder="输入小区名" aria-label="Recipient's username" aria-describedby="basic-addon2">
            </div>
        </div>

        <div class="fottler">
            <div class="btn-group">
                <button class="btn btn-secondary btn-sm dropdown-toggle lianjiean" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    房租
                </button>
                <div class="dropdown-menu" style="padding-left: 10px;">
                    <div class="form-check">
                        <input type="radio" name="money" value="1000以下" class="form-check-input" id="moneyCheckOne" >
                        <label class="form-check-label"  for="moneyCheckOne" >
                            1000以下
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="money" value="1000-2000" class="form-check-input" id="moneyCheckTow" >
                        <label class="form-check-label"  for="moneyCheckTow" >
                            1000-2000
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="money" value="2000-3000" class="form-check-input" id="moneyCheckThree" >
                        <label class="form-check-label"  for="moneyCheckThree" >
                            2000-3000
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="money" value="3000-4000" class="form-check-input" id="moneyCheckFive" >
                        <label class="form-check-label"  for="moneyCheckFive" >
                            3000-4000
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="money" value="4000-5000" class="form-check-input" id="moneyCheckSix" >
                        <label class="form-check-label"  for="moneyCheckSix" >
                            4000-5000
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="money" value="5000以上" class="form-check-input" id="moneyCheckSeven" >
                        <label class="form-check-label"  for="moneyCheckSeven" >
                            5000以上
                        </label>
                    </div>
                </div>
            </div>

            <div class="btn-group">
                <button class="btn btn-secondary btn-sm dropdown-toggle lianjiean" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    房型
                </button>
                <div class="dropdown-menu" style="padding-left: 10px;">
                    <div class="form-check">
                        <input type="radio" name="house" value="不限" class="form-check-input" id="houseCheckOne" >
                        <label class="form-check-label"  for="houseCheckOne" >
                            不限
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="house" value="一室" class="form-check-input" id="houseCheckTwo" >
                        <label class="form-check-label"  for="houseCheckTwo" >
                            一室
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="house" value="二室" class="form-check-input" id="houseCheckThree" >
                        <label class="form-check-label"  for="houseCheckThree" >
                            二室
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="house" value="三室" class="form-check-input" id="houseCheckFour" >
                        <label class="form-check-label"  for="houseCheckFour" >
                            三室
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="house"  value="四室" class="form-check-input" id="houseCheckFive" >
                        <label class="form-check-label"  for="houseCheckFive" >
                            四室
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="house" value="五室" class="form-check-input" id="houseCheckSix" >
                        <label class="form-check-label"  for="houseCheckSix" >
                            五室
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="house" value="五室以上" class="form-check-input" id="houseCheckSeven" >
                        <label class="form-check-label"  for="houseCheckSeven" >
                            五室以上
                        </label>
                    </div>
                </div>
            </div>

            <div class="btn-group">
                <button class="btn btn-secondary btn-sm dropdown-toggle lianjiean" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    面积
                </button>
                <div class="dropdown-menu" style="padding-left: 10px;">
                    <div class="form-check">
                        <input type="radio" name="area" value="50" class="form-check-input" id="areaCheckOne" >
                        <label class="form-check-label"  for="areaCheckOne" >
                            50平以下
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="50-70" class="form-check-input" id="areaCheckTwo" >
                        <label class="form-check-label"  for="areaCheckTwo" >
                            50-70平
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="70-90" class="form-check-input" id="areaCheckThree" >
                        <label class="form-check-label"  for="areaCheckThree" >
                            70-90平
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="90-120" class="form-check-input" id="areaCheckFive" >
                        <label class="form-check-label"  for="areaCheckFive" >
                            90-120平
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="120-150" class="form-check-input" id="areaCheckSix" >
                        <label class="form-check-label"  for="areaCheckSix" >
                            120-150平
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="150-200" class="form-check-input" id="areaCheckSeven" >
                        <label class="form-check-label"  for="areaCheckSeven" >
                            150-200平
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="200" class="form-check-input" id="areaCheckEight" >
                        <label class="form-check-label"  for="areaCheckEight" >
                            200平以上
                        </label>
                    </div>
                </div>
            </div>
        </div>

        <div class="input-group-append">
            <button class="btn btn-outline-secondary" type="button" onclick="areaCheck()">搜索</button>
        </div>
    </div>

</div>

<div class="houseresult">

    <div class="col-md-11" th:each="h:${houses}">
        <div class="housemaptu">
            <img th:src="@{/airent/imgs/fangtu-1.jpg}">
            <div class="housemapturi">
                <h4>无中介费，直租</h4>
                <span th:text="${h.houseType}"> | {{h.rentType}}</span><br>
                <span>工业园区 斜塘路</span><br>
                <div class="redprice">
                    <div style="float: left; font-size: 10px; color: #666675;" th:text="${h.villageName}">东方文荟园</div>
                    <div style="float: right; color: red;"><strong th:text="${h.rentPrice}">900元/月</strong></div>
                </div>
            </div>
        </div>
    </div>

</div>

<div class="map">
    <div id="allmap"></div>
    <div id="r-result"></div>
</div>

<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");

    var point = new BMap.Point(121,31);
    map.centerAndZoom(point,12);
    map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用

    $(function(){
        var areaName=$("#areaName").val();
        //alert(areaName);
        var local = new BMap.LocalSearch(map, {
            renderOptions: {map: map, panel: "r-result"}
        });
        local.search(areaName);

    });


    //按地区搜索
    function areaCheck(){
        var areaName=$("#areaName").val();
        alert(areaName);
        var local = new BMap.LocalSearch(map, {
            renderOptions: {map: map, panel: "r-result"}
        });
        local.search(areaName);

        var money='';

        $("input[name='money']:checked").each(function (i) {
            money+=($(this).val()+",");
        });
        alert(money);

        var house='';
        $("input[name='house']:checked").each(function (i) {
            house+=($(this).val()+",");
        });
        alert(house);

        var area='';
        $("input[name='area']:checked").each(function (i) {
            area+=($(this).val()+",");
        });
        alert(area);


        window.location.href="/map/areaCheck?areaName="+areaName+"&money="+money+"&house="+house+"&area="+area;
        /*$.ajax({
            type:"POST",
            url:"/map/areaCheck",
            dataType:"json",
            data:{
                "areaName":areaName,
                "money":money,
                "house":house,
                "area":area
            },
            success:function(data){

            }
        })*/

    }


</script>




<!-- 地图找房 - 结束 -->

<script th:src="@{/airent/plugins/jquery/jquery.min.js}"></script>
<script th:src="@{/airent/plugins/bootstrap/bootstrap-4.4.1-dist/js/bootstrap.bundle.min.js}"></script>
<script th:src="@{/airent/plugins/bootstrap/bootstrap-4.4.1-dist/js/bootstrap.min.js}"></script>

</body>
</html>
